home *** CD-ROM | disk | FTP | other *** search
/ MacHack 2000 / MacHack 2000.toast / pc / The Hacks / Softshoe / Lisa's Mac Parts / Commands / Commander.h < prev    next >
Text File  |  2000-06-23  |  793b  |  37 lines

  1. // Commander.h
  2.  
  3. #ifndef Commander_h
  4. #define Commander_h
  5.  
  6. #ifndef Assert_h
  7. #include "Assert.h"
  8. #endif
  9. #ifndef CommandLink_h
  10. #include "CommandLink.h"
  11. #endif
  12.  
  13. template < class Protocol >
  14. class Commander
  15.   {
  16.     private:
  17.         typedef CommandLink< Protocol > LinkType;
  18.     
  19.     public:
  20.         Commander()
  21.           {
  22.             Assert( LinkType::ActiveHandler() != 0 );
  23.           }
  24.         
  25.         Protocol& operator*()                    { Assert( !Null() ); return *LinkType::ActiveHandler(); }
  26.  
  27.         Protocol *operator->()                    { Assert( !Null() ); return LinkType::ActiveHandler(); }
  28.         
  29.         const Protocol& operator*() const    { Assert( !Null() ); return *LinkType::ActiveHandler(); }
  30.         
  31.         const Protocol *operator->() const    { Assert( !Null() ); return LinkType::ActiveHandler(); }
  32.  
  33.         static bool Null()                        { return LinkType::ActiveHandler() == 0; }
  34.   };
  35.  
  36. #endif
  37.